package util;

public class Dice {


	public static double D100()
	{
		return Math.floor(Math.random()*100+1);
	}
	
	public static double D100(double min)
	{
		double res=0;
		do
        {
			res= Math.floor(Math.random()*100+1);
        } while (res<min);
		
		return res;
	}

	public static double DNNN(double n)
	{
		return Math.floor(Math.random()*n+1);
	}
		
		public static double D100OpenHand()
		{
			double res = D100();
			
			boolean oo=false;
			boolean up=false;

			if(res>=96)
			{
				oo=true;
				up=true;
				//System.out.println(" oh Up ");
			}

			if(res<=4)
			{
				oo=true;
				up=false;
				//System.out.println(" oh Down ");
			}
			
			while (oo) {
				
				oo=false;				
				double newD100 = D100();
				
				if (up)
					res=res+newD100;
				else
					res=res-newD100;
				
				if(newD100>=96)
				{
					oo=true;
					up=true;
					//System.out.println(" oh Up +"+newD100);
				}

				if(newD100<=4)
				{
					oo=true;
					up=false;
					//System.out.println(" oh Down -"+newD100);
				}
				
			}
			
			
			return res;
		}
}
